//
//  SYuduTableViewCell.m
//  News
//
//  Created by dlios on 15-5-14.
//  Copyright (c) 2015年 PEAK. All rights reserved.
//

#import "SYuduTableViewCell.h"
#import "UIImageView+WebCache.h"
@implementation SYuduTableViewCell

- (void)dealloc
{
    [_biaoti release];
    [_tupian release];
    [_xiangqing release];
    [_myView release];
    [_laiyuan release];
    [_zang release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.myView = [[[UIView alloc] init] autorelease];
       // _myView.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:_myView];
        self.zang = [UIButton buttonWithType:UIButtonTypeSystem];
        [_zang addTarget:self action:@selector(zang) forControlEvents:UIControlEventTouchUpInside];
        [_zang setImage:[UIImage imageNamed:@"iconfont-dianzan"] forState:UIControlStateNormal];
        [_myView addSubview:_zang];
         self.biaoti = [[[UILabel alloc] init] autorelease];
       // self.biaoti.backgroundColor = [UIColor redColor];
        _biaoti.numberOfLines = 0;
        [_myView addSubview:_biaoti];
        self.xiangqing = [[[UILabel alloc] init] autorelease];
        //self.xiangqing.backgroundColor = [UIColor cyanColor];
        _xiangqing.numberOfLines = 0;
        [_myView addSubview:_xiangqing];
        [_xiangqing setFont:[UIFont systemFontOfSize:15]];
        self.tupian = [[[UIImageView alloc] init] autorelease];
        self.tupian.image = [UIImage imageNamed:@"iconfont-shezhi"];
        [_myView addSubview:_tupian];
        self.laiyuan = [[[UILabel alloc] init] autorelease];
        //_laiyuan.backgroundColor = [UIColor redColor];
        [self.myView addSubview:_laiyuan];
        self.zshu = [[[UILabel alloc] init] autorelease];
        //_zshu.backgroundColor = [UIColor greenColor];
        [_myView addSubview:_zshu];
        
    }
    return self;
}
- (void)layoutSubviews
{
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    [super layoutSubviews];
    self.myView.frame = CGRectMake(10, 10, self.contentView.frame.size.width - 20, self.contentView.frame.size.height - 20);
    self.tupian.frame = CGRectMake(0, 0, 90,_myView.frame.size.height - 40);
    self.biaoti.frame = CGRectMake(100, 0, self.myView.frame.size.width - 80, 30);
    //[_biaoti setFont:[UIFont systemFontOfSize:20]];
    self.xiangqing.frame = CGRectMake(100, 40, self.biaoti.frame.size.width - 10, self.myView.frame.size.height - 70);
    _zang.frame = CGRectMake(self.myView.bounds.size.width - 80, self.myView.bounds.size.height - 20, 20, 20);
    [_zang setTintColor:[UIColor redColor]];
    _laiyuan.frame = CGRectMake(0, self.myView.bounds.size.height - 20, 120, 20);
    _zshu.frame = CGRectMake(self.myView.bounds.size.width - 40, self.myView.bounds.size.height - 20, 60, 20);
    
}


//重写read  Set方法
- (void)setRead:(SRead *)read
{
    if (_read != read) {
        [_read release];
        _read = [read retain];
    }
    
    _xiangqing.text = read.digest;
    _biaoti.text = read.title;
    [_tupian sd_setImageWithURL:[NSURL URLWithString:read.img] placeholderImage:[UIImage imageNamed:@"``_3(NZ4U{L@4L7FN0J70DA"]];
    _laiyuan.text = read.source;
    NSString *str = [NSString stringWithFormat:@"%@", read.upTimes];

    _zshu.text = str;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
